package com.winspread.app.lottie

import android.animation.Animator
import com.winspread.active.extension.loge
import com.winspread.app.R
import com.winspread.app.databinding.ActivityLottieBinding
import com.winspread.mvvm.base.vm.BaseNotVmActivity

/**
 * lottie  动画试图
 */
class LottieActivity : BaseNotVmActivity<ActivityLottieBinding>(R.layout.activity_lottie) {


    override fun initView() {
        binding.but1.setOnClickListener {
            binding.animationView.setAnimation("LottieLogo.json")
            binding.animationView.repeatCount = 0
            binding.animationView.progress = 0.5f
//            binding.animationView.speed = -1f
            binding.animationView.playAnimation()
        }

        binding.animationView.addAnimatorListener(object : Animator.AnimatorListener {
            override fun onAnimationStart(animation: Animator?) {
                "onAnimationStart".loge()
            }

            override fun onAnimationEnd(animation: Animator?) {
                "onAnimationEnd".loge()
                binding.animationView.setImageDrawable(getDrawable(R.mipmap.car2))
            }

            override fun onAnimationCancel(animation: Animator?) {
                "onAnimationCancel".loge()
            }

            override fun onAnimationRepeat(animation: Animator?) {
                "onAnimationRepeat".loge()

            }
        })

        binding.animationView.addAnimatorUpdateListener {
            "addAnimatorUpdateListener-->${it.animatedValue}".loge()



        }

    }


}